package hxy.scan.server.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import hxy.scan.server.dao.mapper.HouseMapper;
import hxy.scan.server.dao.model.HouseModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
public class HouseController {


    @Resource
    HouseMapper houseMapper;


    @GetMapping("/house-create")
    public int create(HouseModel bookEntity) {

        String name = bookEntity.getName();

        return houseMapper.insert(bookEntity);
    }

    @GetMapping("/house-list")
    public List<HouseModel> list() {


        return houseMapper.selectList((Wrapper<HouseModel>) null);
    }

    @GetMapping("/house-update")
    public int update(HouseModel bookEntity) {
        // 判断ID

        String address = bookEntity.getAddress();
        int length = address.length();
        String trim = address.trim();

        // 中 国

        return houseMapper.updateById(bookEntity);
    }

    @GetMapping("/house-delete")
    public int delete(int id) {
        return houseMapper.deleteById(id);
    }

}

